package com.hstyle.bms.config.client;
import java.util.List;

import javax.ws.rs.core.MediaType;

import com.hstyle.bms.dto.ShopTradeWhTransDTO;
import com.hstyle.framework.rs.client.RsClient;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.ClientResponse.Status;
import com.sun.jersey.api.client.GenericType;

public class ShopTradeWhClient extends RsClient{

	public ShopTradeWhClient(String baseUrl, String appKey) {
		super(baseUrl, appKey);
		// TODO Auto-generated constructor stub
	}
    
	public ShopTradeWhTransDTO getShopTradeWhByShopOidAndTradeType(String shopOid,String tradetype ){
		 ClientResponse response = client
			.path("/ShopTrade/getShopTrade")
			.queryParam("shopOid", shopOid)
			.queryParam("tradetype", tradetype)
			.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
	        int status = response.getStatus();
	        if (Status.OK.getStatusCode() == status) {
		      return response.getEntity(ShopTradeWhTransDTO.class);
	        } else {
		      return null;
	        }
	}
	
	public List<ShopTradeWhTransDTO> getAllShopTradeList(){
		 ClientResponse response = client
			.path("/ShopTrade/getAllShopTrade")
			.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
	        int status = response.getStatus();
	        if (Status.OK.getStatusCode() == status) {
				return response.getEntity(new GenericType<List<ShopTradeWhTransDTO>>(){});
			} else {
				return null;
			}
	}
}
